<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>查询页面</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #00b09b 0%, #96c93d 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .container {
            width: 100%;
            max-width: 600px;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 12px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
            padding: 40px;
            position: relative;
            overflow: hidden;
        }

        .container::before {
            content: "";
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
            z-index: 0;
        }

        .header {
            text-align: center;
            margin-bottom: 30px;
            position: relative;
            z-index: 1;
        }

        .header h1 {
            color: #2c3e50;
            font-size: 28px;
            margin-bottom: 10px;
        }

        .header p {
            color: #7f8c8d;
            font-size: 16px;
        }

        .form-group {
            margin-bottom: 20px;
            position: relative;
            z-index: 1;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 600;
            color: #2c3e50;
        }

        input[type="text"] {
            width: 100%;
            padding: 14px;
            border: 2px solid #e0e0e0;
            border-radius: 8px;
            font-size: 16px;
            transition: border-color 0.3s;
        }

        input[type="text"]:focus {
            border-color: #00b09b;
            outline: none;
            box-shadow: 0 0 0 3px rgba(0, 176, 155, 0.2);
        }

        .btn {
            width: 100%;
            padding: 14px;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.3s, transform 0.2s;
            display: block;
            text-align: center;
            text-decoration: none;
            margin-top: 10px;
        }

        .btn-query {
            background: #00b09b;
        }

        .btn-query:hover {
            background: #008c7a;
            transform: translateY(-2px);
        }

        .btn-home {
            background: #3498db;
        }

        .btn-home:hover {
            background: #2980b9;
            transform: translateY(-2px);
        }

        .info-box {
            background: #e8f5e9;
            border-radius: 8px;
            padding: 15px;
            margin-top: 20px;
            border-left: 4px solid #4CAF50;
        }

        .info-box p {
            color: #2e7d32;
            margin-bottom: 5px;
        }

        .token-example {
            background: #f5f5f5;
            padding: 10px;
            border-radius: 4px;
            font-family: monospace;
            word-break: break-all;
            margin-top: 10px;
            font-size: 12px;
        }

        .footer {
            text-align: center;
            margin-top: 20px;
            color: #7f8c8d;
            font-size: 14px;
            position: relative;
            z-index: 1;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="header">
        <h1>查询数据</h1>
        <p>需要提供有效的 JWT Token 才能访问</p>
    </div>

    <div class="form-group">
        <label for="token">JWT Token</label>
        <input type="text" id="token" name="token" placeholder="粘贴您的JWT Token" required>
    </div>

    <button id="queryBtn" class="btn btn-query">执行查询</button>
    <a href="index.html" class="btn btn-home">返回登录页面</a>


</div>

<script>
    document.getElementById('queryBtn').addEventListener('click', function() {
        const token = document.getElementById('token').value;

        if (!token) {
            alert('请输入JWT Token');
            return;
        }

        // 使用Fetch API发送请求
        fetch('/query', {
            method: 'GET',
            headers: {
                'Authorization': 'Bearer ' + token
            }
        })
            .then(response => {
                if (response.ok) {
                    return response.text();
                } else {
                    throw new Error('查询失败: ' + response.status);
                }
            })
            .then(html => {
                // 创建新窗口显示结果
                const newWindow = window.open('', '_blank');
                newWindow.document.write(html);
                newWindow.document.close();
            })
            .catch(error => {
                alert(error.message);
            });
    });
</script>
</body>
</html>